/*
**  File: AquaCompl.h
*/
int main( int argc, char *argv[] );
static int Obs_Atoms ( Boolean **obs_atom,
			Strucset *setptr, Strucset *setptr_ref );
static int Obs_Restraints ( DRestraint **DR,
    Distinfl *dist_infl, Distrst *dist_rst, int dist_count,
    Boolean *obs_atom, Strucset *setptr,
    int **rev_mapping_table, Extra_Distinfl *extra_distinfl,
    int *number_not_observable, int *number_not_in_range, int *number_ssa_double,
    int *number_intra,          int *number_low_only,     int *number_nobs_atom );
static int Obs_Pair_Val ( DRestraint **pair, Distvall **distances,
                      Boolean *obs_atom, int obs_atom_count,
		      Strucset *setptr );
static Distval Lowest_Array ( Distval *values, int count );
static Distval Highest_Array ( Distval *values, int count );
static Distval Power_Average_Distval_Array ( Distvall distvall, Distval avg );
static void Copy_Array ( Distval *a, Distval *b, int count );
static Distval Process_Distances_Shells (
    char *atominp, int dist_count,
    Strucset theSet, Strucset theSet_ref, Boolean *obs_atom, int obs_atom_count,
    DRestraint *obs_restr,                int obs_restr_count, int no_restr_count,
    DRestraint *pair, Distvall *pair_val, int obs_pair_count,  int no_pair_count,
    Filnam drst_filnam, Filnam filnam,
    Distinfl *dist_infl, int *rev_mapping_table,
    Filnam rng_filnam );
static int Extract_Pairs ( Boolean *pair_matched,
    DRestraint *pair,      int obs_pair_count,  int no_pair_count);
static int Extract_DR ( Shells  *S_T_restr_ass, DRestraint *obs_restr,
			int obs_restr_count, int no_restr_count );
static void ProcessCompletenessOutput(
	int dist_count, Distval total_compl_fac, int shell_total_count,
	DRestraint  *obs_restr, int obs_restr_count, int no_restr_count,
	DRestraint  *pair,      int obs_pair_count,  int no_pair_count,
	Shells *S_T_restr_ass, int *S_pair_ass,
	Strucset theSet_ref, Strucset theSet,
	Filnam drst_filnam, char *atominp,
	Boolean *obs_atom, int obs_atom_count,
	Filnam filnam, Distinfl *dist_infl, int *rev_mapping_table, Filnam rng_filnam );
static void Show_Explain_AQUA( FILE *fp );
static void Show_General_AQUA( FILE *fp, int dist_count, Strucset theSet );
static void Show_Paramet_AQUA( FILE *fp, Filnam filnam_ob, Filnam rng_filnam );
static void Show_OverSum_AQUA( FILE *fp, Distval total_compl_fac,
	int obs_pair_count,  int no_pair_count,
	int obs_restr_count, int no_restr_count, int shell_total_count,
	int obs_atom_count,  Strucset theSet);
static void Show_AVs_SDs_AQUA( FILE *fp,
    Distval avCc, Distval avCaT, Distval avCrT, Distval avCa, Distval avCr, Distval avCra,
    Distval sdCc, Distval sdCaT, Distval sdCrT, Distval sdCa, Distval sdCr, Distval sdCra );
static void Show_PerClass_AQUA ( FILE *fp,
	DRestraint  *obs_restr, int obs_restr_count, int no_restr_count,
	DRestraint  *pair,      int obs_pair_count,  int no_pair_count,
	Shells *S_T_restr_ass,
	Distval *av, Distval *sd );
static void Show_PerAtom_Type_AQUA ( FILE *fp,
	DRestraint  *obs_restr, int obs_restr_count, int no_restr_count,
	DRestraint  *pair,      int obs_pair_count,  int no_pair_count,
	Shells *S_T_restr_ass, Distval *av, Distval *sd );
static void Show_PerResidue_Type_AQUA ( FILE *fp,
	DRestraint  *obs_restr, int obs_restr_count, int no_restr_count,
	DRestraint  *pair,      int obs_pair_count,  int no_pair_count,
	Strucset theSet, Strucset theSet_ref, Shells *S_T_restr_ass,
	Distval *av, Distval *sd );
static void Show_PerResidue_AQUA ( FILE *fp,
	DRestraint  *obs_restr, int obs_restr_count, int no_restr_count,
	DRestraint  *pair,      int obs_pair_count,  int no_pair_count,
	Strucset theSet, Strucset theSet_ref, Shells *S_T_restr_ass,
	Distval *av, Distval *sd );
static void Show_PerAtom_AQUA ( FILE *fp,
	DRestraint  *obs_restr, int obs_restr_count, int no_restr_count,
	DRestraint  *pair,      int obs_pair_count,  int no_pair_count,
	Strucset theSet, Shells *S_T_restr_ass,
	Boolean *obs_atom, int obs_atom_count,
	Distinfl *dist_infl, int *rev_mapping_table, int dist_count,
	Distval *av, Distval *sd );
static void Show_PerResAtom_AQUA ( FILE *fp,
	DRestraint  *obs_restr, int obs_restr_count, int no_restr_count,
	DRestraint  *pair,      int obs_pair_count,  int no_pair_count,
	Strucset theSet, Strucset theSet_ref, Shells *S_T_restr_ass,
	Distinfl *dist_infl, int *rev_mapping_table, int dist_count,
	Distval *av, Distval *sd );
static Boolean Same_Floats (Distval a, Distval b);
static Distval Average_Float_Array ( Distval *f_array,
	int count, int skip_count );
static Distval SD_Float_Array ( Distval *f_array,
	int count, int skip_count );
static void Partition_Restraints_Classes (
    DRestraint *obs_restr, int obs_restr_count, int no_restr_count,
    int **rst_count, Boolean do_no_rst_count, int **no_rst_match_count,
    Shells *S_T_restr_ass );
static void Partition_Restraints_AtomT (
    DRestraint *obs_restr, int obs_restr_count, int no_restr_count,
    int **rst_count, Boolean do_no_rst_count, int **no_rst_match_count,
    Shells *S_T_restr_ass );
static void Partition_Restraints_ResidueT (
    DRestraint *obs_restr, int obs_restr_count, int no_restr_count,
    int **rst_count, Boolean do_no_rst_count, int **no_rst_match_count,
    Shells *S_T_restr_ass, ID *resID, int num_list );
static void Partition_Restraints_Residue (
    DRestraint *obs_restr, int obs_restr_count, int no_restr_count,
    int **rst_count, Boolean do_no_rst_count, int **no_rst_match_count,
    Shells *S_T_restr_ass, Strucset theSet );
static void Partition_Restraints_Atom (
    DRestraint *obs_restr, int obs_restr_count, int no_restr_count,
    int **rst_count, Boolean do_no_rst_count, int **no_rst_match_count,
    Shells *S_T_restr_ass, int *list_idx,
    int obs_atom_count,
    Distinfl *dist_infl, int *rev_mapping_table, int dist_count );
static void Partition_Restraints_ResAtom (
    DRestraint *obs_restr, int obs_restr_count, int no_restr_count,
    int **rst_count, Boolean do_no_rst_count, int **no_rst_match_count,
    Shells *S_T_restr_ass,
    Strucset theSet, Strucset theSet_ref,
    Distinfl *dist_infl, int *rev_mapping_table, int dist_count );
static int Categorize_Pairs ( Distval max, int shell_num,
    DRestraint *pair, Distvall *pair_val, int *S_pair_ass, int obs_pair_count,
    int no_pair_count );
static void Fill_Int_Array( int *m, int value, int nrl, int nrh);
static void Fill_Boolean_Array( Boolean *m,  Boolean value, int nrl, int nrh);
static void Fill_2Int_Array( Shells *m, int value1, int value2,
				    int nrl, int nrh);
static int Match_Rsts_Pairs ( int s,
    DRestraint *obs_restr, Shells *S_T_restr_ass, int obs_restr_count, int no_restr_count,
    DRestraint *pair, int *S_pair_ass, int obs_pair_count,
    Distinfl *dist_infl, int *rev_mapping_table,
    Boolean *pair_matched );
static Boolean Same_Partners_DRestraint ( DRestraint P, DRestraint Q,
Distinfl *dist_infl, int r );
static void ShowSummary (
		    int obs_restr_count,   int obs_pair_count,
		    Shells *S_T_restr_ass, int *S_pair_ass);
static void Show_Summary_AQUA ( FILE *fp,
    int obs_restr_count,   int obs_pair_count,
    Shells *S_T_restr_ass, int *S_pair_ass);
static int Count_Restraint_S ( int shells_s, Shells *S_T_restr_ass,
				int obs_restr_count );
static int Count_Restraint_S_T ( int shells_s, int shells_t,
			Shells *S_T_restr_ass, int obs_restr_count );
static int Count_Pair_S ( int shells_s, int *S_pair_ass, int obs_pair_count );
static char Boolean_To_Char(Boolean boo);
static Boolean Same_Residue (Atom a, Atom b);
static void Match_SSA ( Strucset *setptr, Distinfl *dist_infl, int dist_count  );
static Boolean Same_Atom ( Atom atom_A, Psatom psatom_B );
static void Show_Type_SSA_info_AQUA ( FILE *fp,
	Psatom *stereo_list,
	Boolean *stereo_assigned, int stereo_count, int total_ssa );
static void Show_SSA_info_AQUA ( FILE *fp,
	    	Psatom *stereo_list,
		Boolean *stereo_assigned, int stereo_count );
static Boolean Concatenate_file_A_To_B ( char *file_a,  char *file_b );
static void WriteFPsatom ( FILE *fp, Psatom psatom );
static Boolean SameResidueT_Atom ( Atom A, Atom B );
static Boolean Check_Options ( void );
